//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#include "aura.h"
#include "wince.h"
#include "private.h"

AURA_API_(Aura_ProcessId) AuraProcess_GetCurrentId()
{
    return GetCurrentProcessId();
}

AURA_API_(Aura_Void) AuraProcess_Exit(
        /* [in] */ Aura_ExitCode exitCode)
{
    ExitProcess((UINT)exitCode);
    assert(0);  // can not reach here.
}

AURA_API AuraProcess_GetStartInfo(
        /* [out] */ Aura_PWChar pwImageName,
        /* [out] */ Aura_PWChar pwArguments)
{
#define __MAX_PATH__ 260
    DWORD   length = 0;
    wchar_t fileName[__MAX_PATH__];
    wchar_t * pSlash = NULL;
    wchar_t * pImageName = (wchar_t *)pwImageName;
    wchar_t * pArguments = (wchar_t *)pwArguments;

    length = GetModuleFileNameW(NULL, fileName, __MAX_PATH__);
    if (!length) {
        goto E_FAIL_EXIT;
    }
    pSlash = wcsrchr(fileName, L'\\');
    wcscpy(pImageName, pSlash + 1);

    wcscpy(pArguments, GetCommandLineW());

    return AURA_NOERROR;

E_FAIL_EXIT:
    return GetLastAuraECode();
}

AURA_API AuraProcess_GetPriorityRank(
        /* [out] */ Aura_ThreadPriorityRank * pPriorityRank)
{
    assert(NULL != pPriorityRank);
    // See MSDN: Windows CE does not support priority classes.
    // The order in which threads are scheduled is determined
    // only by their thread priorities.
    FixMe("Not Supported.");
    return AURA_E_NOT_SUPPORTED;
}

AURA_API AuraProcess_SetPriorityRank(
        /* [out] */ Aura_ThreadPriorityRank priorityRank)
{
    FixMe("Not Supported.");
    return AURA_E_NOT_SUPPORTED;
}

AURA_API AuraProcess_GetProcessorTimes(
        /* [out] */ Aura_Millisecond32 * pUserTime,
        /* [out] */ Aura_Millisecond32 * pPrivilegedTime)
{
    FixMe("Not Supported.");
    return AURA_E_NOT_SUPPORTED;
}

AURA_API AuraProcess_GetMemoryInformation(
        /* [out] */ Aura_Int32 * pPrivateVirtualMemorySize,
        /* [out] */ Aura_Int32 * pSharedVirtualMemorySize,
        /* [out] */ Aura_Int32 * pPrivatePhysicalMemorySize,
        /* [out] */ Aura_Int32 * pSharedPhysicalMemorySize)
{
    FixMe("Not Implemented yet.");
    return AURA_E_NOT_IMPLEMENTED;
}

